#!/bin/bash

# Copyright 2023 TikTok Pte. Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

BIN_DIR="@BIN_DIR@"
JSON_DIR="@JSON_DIR@"
LOG_DIR="@LOG_DIR@"

mkdir -p "${LOG_DIR}/dpca-psi/test/balanced"
mkdir -p "${LOG_DIR}/dpca-psi/test/unbalanced"

sender_feature_size=1
default_tau_array=(722)
balanced_log_path_bandwith="${LOG_DIR}/dpca-psi/test/balanced"
echo "Sender balanced test"
balanced_intersection_size_array=(500)
for(( i=0;i<${#balanced_intersection_size_array[@]};i++))
do
echo "Test intersection size ${balanced_intersection_size_array[i]}"
echo "with dp"
"${BIN_DIR}/dpca_psi_example" --config_path="${JSON_DIR}/sender_with_precomputed_tau.json" --log_path=$balanced_log_path_bandwith --use_random_data=true --intersection_size=${balanced_intersection_size_array[i]} --intersection_ratio=2 --feature_size=$sender_feature_size --use_default_tau=true --default_tau=${default_tau_array[i]}
echo "without_dp"
"${BIN_DIR}/dpca_psi_example" --config_path="${JSON_DIR}/sender_without_dp.json" --log_path=$balanced_log_path_bandwith --use_random_data=true --intersection_size=${balanced_intersection_size_array[i]} --intersection_ratio=2 --feature_size=$sender_feature_size
done

unbalanced_log_path_bandwith="${LOG_DIR}/dpca-psi/test/unbalanced"
echo "Sender unbalanced test"
unbalanced_intersection_size_array=(10)
for(( i=0;i<${#unbalanced_intersection_size_array[@]};i++))
do
echo "Test intersection size ${unbalanced_intersection_size_array[i]}"
echo "with dp"
"${BIN_DIR}/dpca_psi_example" --config_path="${JSON_DIR}/sender_with_precomputed_tau.json" --log_path=$unbalanced_log_path_bandwith --use_random_data=true --intersection_size=${unbalanced_intersection_size_array[i]} --intersection_ratio=100 --feature_size=$sender_feature_size --use_default_tau=true --default_tau=${default_tau_array[i]}
echo "without_dp"
"${BIN_DIR}/dpca_psi_example" --config_path="${JSON_DIR}/sender_without_dp.json" --log_path=$unbalanced_log_path_bandwith --use_random_data=true --intersection_size=${unbalanced_intersection_size_array[i]} --intersection_ratio=100 --feature_size=$sender_feature_size
done
